package cate.game.pvp.guildwar.data.base;

import cate.game.db.mongo.kv.KvMongo;
import cate.game.pvp.guildwar.data.GWGuildProfile;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.ArrayList;
import java.util.List;

@EqualsAndHashCode(callSuper = true)
@Data
@NoteClass("公会战本服数据")
public class GuildWarKV extends KvMongo {

    @NoteField("当前赛季")
    public int index;

    @NoteField("赛季开始时间")
    public long startTime;

    @NoteField("赛季结束时间")
    public long endTime;

    @NoteField("本服是否报名成功")
    public boolean sign;

    @NoteField("本次能报名的公会")
    public List<GWGuildProfile> signUpGuilds;

    @NoteField("公会战时间表")
    public GuildWarTimeTable timeTable;

    @NoteField("匹配过")
    public boolean match;

    @Override
    public String getKeyPrefix() {
        return KvMongo.KEY_GUILD_WAR_GAME;
    }

    @Override
    public void initialize() {
        if (signUpGuilds == null) {
            signUpGuilds = new ArrayList<>();
        }
        if (timeTable == null) {
            timeTable = new GuildWarTimeTable();
        }
        timeTable.initialize();
    }

    public void onDaySpan(){
        sign = false;
        signUpGuilds.clear();
        timeTable.clear();
        match = false;
    }
}
